package org.sidora.core.context;

import java.awt.BasicStroke;
import java.awt.Color;
import java.net.URL;
import java.util.HashSet;

import javax.swing.ImageIcon;
import org.sidora.core.Category;
import org.sidora.core.MeasureSet;


/**
 * BuildedContext
 * @author Enric Tartera, Juan Manuel Gimeno, Roger Masgoret
 * @version 1.0
 */
public class BuildedContext extends Context{
	
	public Category buildingTechnique;
	public Category buildingMaterial;
	public Category bondingMaterial;
	public Category coursing;
	private MeasureSet measures;

        public BuildedContext(){
            measures = new MeasureSet();
        }
        
        //TODO icon
	public ImageIcon getIcon() {
		return new javax.swing.ImageIcon(getClass().getResource("/org/sidora/core/context/resources/builded16.png"));
	}
	
//	public ColorItem getColorItem(){
//	
//		ColorItem colorItem= new ColorItem(	new Color(222,204,190),new Color(90,74,64),
//				new BasicStroke(2.0F,BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND));
//		return colorItem;
//	}
	public String getStringClass() {
		
		return "Builded";
	}
//	public HashSet<Variable> getVariableSet() {
//		HashSet<Variable> vSet = new HashSet<Variable>();
//		String [] labels = {"Material","Aparell","Disposici�","T?cnica","Lligam",
//				"Amplada", "Llargada", "Al?ada"};
//		
//		for (int i =0 ; i< labels.length; i++){
//			Variable var = new Variable();
//			var.setLabel(labels[i]);
//			var.setReferencedClass(this.getStringClass());
//			vSet.add(var);
//		}
//		return vSet;
//		
//	}
	public String outputVariables(){
		String bmat = "";
		if (buildingMaterial!=null) bmat = buildingMaterial.getValue();
		String cou = "";
		if (coursing!=null) cou = coursing.getValue();
		String btec = "";
		if (buildingTechnique!=null) btec = buildingTechnique.getValue();
		String bon = "";
		if (bondingMaterial!=null) bon = bondingMaterial.getValue();
		
	
		StringBuffer buf = new StringBuffer();
		buf.append("<html>");
		buf.append("<body>");
		
		buf.append("<table width=\'100%\' border=\'0\' cellspacing=\'0\' cellpadding=\'1\' bgcolor=\'white\'>");
		buf.append("		<tr align=\'right\'bgcolor=\'#DECCBE\'>");
		buf.append("			<th align=\'right\'><font size=\'3\'color=\'black\' face=\'Lucida\'>Categories:</font></th>");
		buf.append("			<th align=\'left\'></th>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Material:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+bmat+"</font></td>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Aparell:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+cou+"</font></td>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>T?cnica:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+btec+"</font></td>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Lligam:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+bon+"</font></td>");
		buf.append("		</tr>");
		buf.append("</table>");
		
		if (measures!=null){
		
		buf.append("<table width=\'100%\' border=\'0\' cellspacing=\'0\' cellpadding=\'1\' bgcolor=\'white\'>");
		buf.append("		<tr align=\'right\'bgcolor=\'#fac1a2\'>");
		buf.append("			<th align=\'right\'><font size=\'3\'color=\'black\' face=\'Lucida\'>Mides:</font></th>");
		buf.append("			<th align=\'left\'></th>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Ample:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+measures.getLength()+"</font></td>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Llarg:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+measures.getWidth()+"</font></td>");
		buf.append("		</tr>");
		buf.append("		<tr>");
		buf.append("			<td align=\'right\' width=\'25%\'><font size=\'3\'color=\'black\' face=\'Lucida\'><em>Alt:</em></font></td>");
		buf.append("			<td><font size=\'3\'color=\'black\' face=\'Lucida\'>"+measures.getHeight()+"</font></td>");
		buf.append("		</tr>");
		buf.append("</table>");
		}
		
		buf.append("</body>");
		buf.append("</html>");
		
		return buf.toString();
	}

    public Category getBuildingTechnique() {
        return buildingTechnique;
    }

    public void setBuildingTechnique(Category buildingTechnique) {
        this.buildingTechnique = buildingTechnique;
    }

    public Category getBuildingMaterial() {
        return buildingMaterial;
    }

    public void setBuildingMaterial(Category buildingMaterial) {
        this.buildingMaterial = buildingMaterial;
    }

    public Category getBondingMaterial() {
        return bondingMaterial;
    }

    public void setBondingMaterial(Category bondingMaterial) {
        this.bondingMaterial = bondingMaterial;
    }

    public Category getCoursing() {
        return coursing;
    }

    public void setCoursing(Category coursing) {
        this.coursing = coursing;
    }

    public MeasureSet getMeasures() {
        return measures;
    }

    public void setMeasures(MeasureSet measures) {
        this.measures = measures;
    }
}